<template>
	<view class="page">
		<view class="padding">
			<view class='page-head'>
				<view class="page-title text-lg text-bold text-black padding-bottom-xs">
					知识答题活动
				</view>
				<view>共{{questionNum}}题，满分100分</view>
				<view class='page-score'>
					<text class="score-num text-red text-bold">{{totalScore}}分</text>
				</view>
			</view>
			<view class='page-footer'>
				<view class='padding flex text-center text-grey bg-white radius margin-bottom'>
					<view class='flex flex-sub flex-direction solid-right'>
						<view class="text-xxl text-red">{{questionNum-wrong}}题</view>
						<view class="margin-top-sm">
							答对</view>
					</view>
					<view class='flex flex-sub flex-direction solid-right'>
						<view class="text-xxl text-gray">{{wrong}}题</view>
						<view class="margin-top-sm">
							答错</view>
					</view>
					<view class='flex flex-sub flex-direction'>
						<view class="text-green text-xxl">
							{{zql}}%
						</view>
						<view class="margin-top-sm">
							正确率</view>
					</view>
				</view>
				<view class="flex padding flex-direction">
					<button @click="toDoTestAgain" hover-class="other-button-hover" class="cu-btn bg-red round lg">
						再答一次 </button>
					<button @click="toIndex" hover-class="other-button-hover"
						class="cu-btn line-red round lg margin-top"> 返回首页 </button>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				totalScore: null,
				wrong: 0,
				zql: null,
				questionNum: 0
			}
		},
		methods: {
			// 再答一次
			toDoTestAgain() {
				uni.redirectTo({
					url: '../test/test'
				})
			},
			// 返回首页
			toIndex() {
				uni.redirectTo({
					url: '../index/index'
				})
			},
		},
		onLoad(options) {
			this.questionNum = options.questionNum
			// 查看答题成绩
			uni.showLoading({
				title: '系统判分中'
			});
			this.zql = (this.questionNum - this.wrong) / this.questionNum * 100
			this.totalScore = this.zql / 100 * 100;
			this.wrong = options.wrong
			uni.hideLoading();
		},
		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage() {
			return {
				title: '@你，快来参与知识答题活动吧~'
			}
		},
	}
</script>

<style>
	page {
		background-color: #fff;
	}

	.page {
		padding: 30rpx;
	}

	.mw-avatar {
		width: 128rpx;
		height: 128rpx;
		border-radius: 50%;
		overflow: hidden;
	}

	.page-score {
		display: flex;
		justify-content: center;
		align-items: flex-end;
		padding-top: 20rpx;
		padding-bottom: 20rpx;
	}

	.score-num {
		font-size: 100rpx;
	}

	.page-footer {
		margin-top: 50rpx;
		text-align: center;
	}
</style>